package com.service;

import com.dao.UserDao;
import com.entity.User;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service("userService")
public class UserServiceImpl implements UserService {
    private UserDao dao;

    @Resource
    public void setUserDao(UserDao userDao){this.dao=userDao;}

    public void setDao(UserDao dao){
        this.dao=dao;
    }

    @Override
    public void addNewUser(User user) {
        dao.save(user);
    }

    //无参构造
    public UserServiceImpl(){ }

    //用于为dao属性赋值的构造方法
    public UserServiceImpl(UserDao dao){
        this.dao=dao;
    }
}
